/********************************************
 * WARNING: This file will be removed soon! *
 *          Please use a hashmap instead.   *
 *          (better performance, usually)   *
 ********************************************/

// TODO: remove this file, after (httpd|request|tag).c doesn't need a dict anymore

#ifndef DICT_H
#define DICT_H 1

#include "main.h"
#include "bool.h"
#include "array.h"
#include "string.h"

#ifndef DICT_INITSIZ
# define DICT_INITSIZ 3
#endif

typedef struct __ncattr__ dict {
  bool __make_copy;
  struct array *elems;
} dict_t;

typedef struct __ncattr__ dict_elem {
  char *key;
  char *value;
} dict_elem_t;

dict_t *
create_dict(bool malloc_kv_ptr);

void
free_dict(dict_t *dict);

size_t
dict_len(dict_t *dict);

dict_elem_t *
get_dict_elem(dict_t *dict, size_t idx);

long int
insert(dict_t *dict, const char *key, size_t klen, const char *value, size_t vlen);

long int
insert_s(dict_t *dict, const char *key, const char *value);

long int
insert_f(dict_t *dict, const char *key, const char *fmt, ...);

long int
insert_str(dict_t *dict, string_t *key, string_t *value);

const char *
lookup(dict_t *dict, const char *key);

#ifdef ENABLE_DEBUG
void
print_dict_debug(dict_t *dict);
#else
# define print_dict_debug(x);
#endif

#endif
